#ifndef __INCLUDED_CBL_FREELIST_H__
#error "CBL_FreeList.hpp must not be used directly. Use CBL_FreeList.h instead."
#else
#ifndef __INCLUDED_CBL_FREELIST_HPP__
#define __INCLUDED_CBL_FREELIST_HPP__

template <typename TClassName>
inline TClassName* CFreeList::Allocate()
{
    if (Debug::Verify(sizeof(TClassName) == m_BlockSizeByte, "Class does not fit freelist blocksize."))
    {
        TClassName* pObject = new (NextAvailableBlock()) TClassName();
        return pObject;
	}
    
    return NULL;
}

// -------------------------------------------------------------------------------------------------

inline void* CFreeList::Allocate(size_t _Size)
{
    if (Debug::Verify(_Size == m_BlockSizeByte, "Class does not fit freelist blocksize."))
    {
        return NextAvailableBlock();
    }
    
    return NULL;
}

// -------------------------------------------------------------------------------------------------

template <typename TClassName>
inline void CFreeList::Free(TClassName* _pObject)
{
    m_FreeBlocks.push_back(reinterpret_cast<uint8*>(_pObject));
    _pObject->~TClassName();
}

// -------------------------------------------------------------------------------------------------

inline void CFreeList::Free(void* _pObject)
{
    m_FreeBlocks.push_back(reinterpret_cast<uint8*>(_pObject));
}

#endif
#endif